import React from 'react';
import {connect} from 'dva'

import { BasicAbstract } from 'components/Abstract'
import Title from 'components/Title'

@connect(({maintenance}) => ({...maintenance}))
class Indicators extends React.Component {
    static defaultProps = {
        abstractConf: {
            label: '重点指标监控', list: [
              { label: '工单总数', field: 'OrderCount', unit: '个', icon: 'order_total' },
              { label: '今日工单', field: 'Today', unit: '个', icon: 'order_today' },
              { label: '完结工单', field: 'Finish', unit: '个', icon: 'order_complete' },
              { label: '超期工单', field: 'Overdue', unit: '个', icon: 'order_delay' },
              { label: '巡检里程', field: 'cxcl', unit: '公里', icon: 'location' },
              { label: '巡检数量', field: 'Point', unit: '座', icon: 'num' }
            ]
          },
    }

  componentDidMount() {
    this.init();
  }

  init = async () => {
    await this.setDateIndicators()
  }
  // 获取指标
  setDateIndicators = async () => {
    await this.props.dispatch({
      type: 'maintenance/queryIndicators'
    });
  }

  render() {
    const { label, list } = this.props.abstractConf;

    const { IndicatorsResource: dataSource } = this.props
    return (
      <Title title={label}  style={{'paddingLeft': '4%', 'paddingRight': '4%'}}>
        <BasicAbstract
          columns={list}
          dataSource={dataSource}
          className={'col-12'}/>
      </Title>
    )
  }
}

export default Indicators;
